package com.venus.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.venus.entity.Sign;
import com.venus.entity.User;
import com.venus.service.SignService;
import com.venus.util.PageUtil;
import com.venus.util.Result;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

/**
 * <p>
 * 签到表 sign 前端控制器
 * </p>
 *
 * @author Venus
 * @since 2020-06-08
 */
@Controller
@RequestMapping("/sign")
public class SignController {
    @Resource
    private SignService signService;


    @RequestMapping("/select")
    public Object selectUser(Sign sign, PageUtil pu) {
        //获取分页信息
        //getPage()为当前页码  pu.getLimit()为每页显示条数
        Page<Sign> page = new Page<Sign>(pu.getPage(), pu.getLimit());
        //创建实体包装类   用于存放查询条件
        QueryWrapper<Sign> select = new QueryWrapper<Sign>();
        //根据名字模糊查询
        if (sign.getSignName() != null && !sign.getSignName().isEmpty()) {
            select.like("user_name", sign.getSignName());
        }
        if (sign.getSignStatus() != null && !sign.getSignStatus().isEmpty()) {
            select.like("user_id", sign.getSignStatus());
        }
        /*遗留签到时间的查询*/

        //分页查询方法
        page = signService.page(page, select);
        //getRecords()获取page中的集合数据
        //getTotal()获取总条数
        return new Result(0, "success", page.getRecords(), page.getTotal());
    }




}
